﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _14_超市收银系统
{
    /// <summary>
    /// 买M元，送N元
    /// </summary>
    class CalMN : CalFather
    {
        /// <summary>
        /// 买了M元
        /// </summary>
        public double M { get; set; }

        /// <summary>
        /// 买了M元后送了N元
        /// </summary>
        public double N { get; set; }

        public CalMN(double m, double n)
        {
            this.M = m;
            this.N = n;
        }

        public override double GetTotalMoney(double realMoney)
        {
            if (realMoney >= this.M)
            {
                return realMoney - (int)(realMoney / this.M) * this.N;//满500减50，满1000减100
            }
            else
            {
                return realMoney;
            }
        }
    }
}
